using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : Entity
{
    [SerializeField] protected LayerMask WhatIsPlayer;
    public float playerDistance = 5f;
    [Header("Move info")]
    public float moveSpeed = 2f;
    public float idleTime = 1f;
    [Header("Attack info")]
    
    public float attackDistance = 2f;
    public float attackCoolDown = 0.4f;
    public float battleTime = 4f;
    [HideInInspector]public float lastAttackTime;
    public EnemyState enemyState { get; private set; }
    #region state
    public EnemyStateMachine stateMachine { get; private set; }
    #endregion
    protected override void Awake()
    {
        base.Awake();
        stateMachine = new EnemyStateMachine();
    }
    protected override void Start()
    {
        base.Start();
       
       
    }
    protected override void Update()
    {
        base.Update();
        stateMachine.currentState.Update();
        
    }
    public virtual void AnimationFinishTrigger() => stateMachine.currentState.AnimationFinishTrigger();
    public virtual RaycastHit2D isPlayerDetected() => Physics2D.Raycast(wallCheck.position, Vector2.right * facingDir, playerDistance, WhatIsPlayer);
    protected override void OnDrawGizmos()
    {
        base.OnDrawGizmos();
        Gizmos.color = Color.yellow;
        Gizmos.DrawLine(transform.position, new Vector3(transform.position.x + attackDistance * facingDir, transform.position.y));
    }

}
